Skip to content

fix(watch): walk all seller pages so removal detection stays truthful - #56

Merged
Microck merged 4 commits into
Microck:mainfrom
JcMinarro:fix/watch-seller-pagination
Nov 15, 2026
Merged

Microck merged 4 commits into
Microck:mainfrom
JcMinarro:fix/watch-seller-pagination

Conversation

@JcMinarro

@JcMinarro JcMinarro commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Problem

checkSeller in internal/watch/watch.go compared the seen hashes against only the first page of the seller's items (Client.UserItems, 40 items). With sellers holding more than 40 active listings, every check emitted false item.removed events for items that had merely scrolled to a later page — and ghost item.new recoveries when they scrolled back. The misleading comment claimed "The seller's list is complete, so a missing hash really is gone".

Pre-existing bug (the real API already paginated before #55), but #55 built the tool to fix it — this stacks on top.

Changes

  • New Client.UserItemsAll(ctx, hash, since): sequential, strictly non-concurrent bounded walk returning the pending cursor when MaxItemWalkPages (50 pages) truncates the list.
  • maxOwnItemPages renamed to exported MaxItemWalkPages, now the single bound shared by MyItem, UserItemsAll and the CLI's --all.
  • checkSeller uses the walk and skips the removal sweep while the list is truncated: an absent hash may sit on an unfetched page, so staying silent beats a false alarm. user items --all reuses the same walk, removing the duplicated loop.

Tests

  • TestSellerWatchWalksAllPages: with a 2-item page size, an item on page 2 is tracked; removing page-1 and page-2 items each yields exactly one truthful item.removed.
  • TestSellerWatchDoesNotReportRemovedWhenWalkTruncates: 55 items on a 1-item page — the bounded check stays silent instead of lying, and issues exactly 50 page requests per check.
  • Full suite green (239 tests).

Summary by Sourcery

Walk seller listings across pages while suppressing removal detection when pagination cannot establish a complete view.

New Features:

  • Add paginated seller item retrieval with resumable single-page and bounded full-walk CLI modes.

Bug Fixes:

  • Prevent seller watches from reporting false removals when listings are on later pages or pagination is incomplete.

Enhancements:

  • Share a single bounded page-walk limit across listing searches, seller retrieval, and the CLI.
  • Preserve partial results and cursors when pagination is truncated, stalls, or encounters a later-page failure.

Documentation:

  • Document seller item pagination, bounded full walks, and cursor resumption options.

Tests:

  • Add coverage for multi-page retrieval, walk bounds, cursor failures, partial results, and truthful seller-removal detection.

Review follow-up

  • The shared UserItemsAll walk preserves successful pages and the cursor if a later request fails; a repeated nonempty cursor is an explicit error with partial results/cursor preserved. The CLI prints that partial response before reporting the error.
  • checkSeller returns without a removal sweep on a stalled/error walk, and suppresses removal detection when the successful walk hits its page bound. This avoids declaring unfetched Items gone.
  • Added a regression test for a stalled cursor in seller watch.

Verification: go test ./... -count=1 (242 tests) and go build ./... passed.

Stacked on #55 — merge #55 first; this branch is based on its updated head.


Stacked on #55 — this branch is based on #55's updated head; merge #55 first. This PR currently targets main because GitHub's API rejects a fork-only base branch. If #55 is squash-merged, this branch may need retargeting/rebasing before merge.

… --all

The user-items endpoint pages 40 items at a time through meta.next/?since=,
but Client.UserItems discarded the cursor, so sellers with more than 40
active listings were unreachable.

- Add Client.UserItemsPage(ctx, hash, since) returning one page plus cursor.
- `user items USER` gains --next (resume from a previous next_page token)
  and --all (sequential bounded walk, 50 pages max, stops with a warning
  and keeps the pending cursor in next_page when the bound is hit).
- Without flags the output shape is unchanged apart from the additive
  next_page field.
- Fake server now paginates /api/v3/users/{hash}/items like /user/items.
@vercel

vercel Bot commented Nov 15, 2026

Copy link
Copy Markdown

@JcMinarro is attempting to deploy a commit to the Projects Team on Vercel.

A member of the Team first needs to authorize it.

@sourcery-ai

sourcery-ai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Reviewer's Guide

Data structures

Expose the shared page-walk limit and add the seller-item page and bounded-walk client interfaces, including cursor and partial-result behavior.

  • internal/wallapop/items.go L117, L134, L139-142
  • internal/wallapop/users.go L6, L141-177

Uses of the API

Use the bounded seller-item walk for watch checks and suppress removal events whenever pagination leaves the listing set incomplete.

  • internal/watch/watch.go L194, L210-221

Implementation

Implement fake seller-item pagination and controls for request failures and cursors that do not advance.

  • internal/fakewallapop/fake.go L128-136, L269-274, L546-563 (+3 small edits)

UI

Add user-items pagination flags, print resumable page or partial-walk results, and warn when the bounded walk leaves more pages.

  • internal/cli/item.go L578-587, L597-645, L651-658

Documentation

Document page cursors, bounded --all walks, and resuming seller-item listings with --next.

  • docs-site/content/docs/reference/user.mdx L16-37

Tests

Cover CLI pagination, resume cursors, bounded and failed walks, and seller-watch behavior for later pages, truncation, and stalled cursors.

  • internal/cli/cli_test.go L519-733

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai

coderabbitai Bot commented Nov 15, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 33 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 3c6a5843-1faa-42fe-8afd-8a63e0f2426a
Commits

Reviewing files that changed from the base of the PR and between 45da2fa and fa953bc.

Files selected for processing: 7

  • docs-site/content/docs/reference/user.mdx
  • internal/cli/cli_test.go
  • internal/cli/item.go
  • internal/fakewallapop/fake.go
  • internal/wallapop/items.go
  • internal/wallapop/users.go
  • internal/watch/watch.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've found 10 issues

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path="internal/wallapop/users.go" line_range="165" />
<code_context>
+		}
+		items = append(items, batch...)
+		// A cursor repeated unchanged would loop forever; treat it as done.
+		if cursor == "" || cursor == since {
+			return items, "", nil
+		}
</code_context>
<issue_to_address>
**Missing Items reported removed**

When the API repeats a nonempty next cursor while seller Items remain, `UserItemsAll` returns an empty truncation marker, so `checkSeller` treats the partial result as complete and emits false `item.removed` events; `user items --all` also loses the continuation marker.

Mark repeated-cursor walks as truncated, have `checkSeller` skip removals, and preserve the truncation or continuation state for callers.

Also at `internal/watch/watch.go:214`.
</issue_to_address>

### Comment 2
<location path="internal/watch/watch.go" line_range="194" />
<code_context>
 func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
 	var res Result
-	items, err := c.UserItems(ctx, t.Hash)
+	items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")
 	if err != nil {
 		return Result{}, err
</code_context>
<issue_to_address>
**Existing Items reported as new**

When a seller exceeds 50 pages and a previously unfetched Item later enters the fetched range, `checkSeller` emits new-item events from partial results and `CommitCheck` marks a truncated baseline complete, so the existing Item is absent from `seen` and appears new.

Keep truncated baselines incomplete and defer new-item events until a complete walk can establish the prior set.

Also at `internal/watch/watch.go:214`.
</issue_to_address>

### Comment 3
<location path="internal/watch/watch.go" line_range="194" />
<code_context>
 func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
 	var res Result
-	items, err := c.UserItems(ctx, t.Hash)
+	items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")
 	if err != nil {
 		return Result{}, err
</code_context>
<issue_to_address>
**Overlapping checks duplicate events**

When a scheduled check overlaps a manual or second scheduled check for the same watch, two `watch check` runs can read the same prior `seen` state while this multi-page walk is in progress, independently produce the same events, deliver them, and commit them. SQLite’s single-writer setting serializes writes but not the fetch-and-diff interval, so users receive duplicate notifications; an older run can also commit stale state after a newer one.

Serialize checks per watch or use a version/lease mechanism that prevents stale checks from delivering and committing after a newer check.
</issue_to_address>

### Comment 4
<location path="internal/wallapop/users.go" line_range="163" />
<code_context>
+		if err != nil {
+			return items, "", err
+		}
+		items = append(items, batch...)
+		// A cursor repeated unchanged would loop forever; treat it as done.
+		if cursor == "" || cursor == since {
</code_context>
<issue_to_address>
**Overlapping pages produce duplicates**

When seller listings shift between page requests and an Item appears on multiple pages, `UserItemsAll` appends repeated hashes and `checkSeller` compares each copy against the unchanged prior `seen` map, so `user items --all` returns duplicate rows and a check emits duplicate events.

Deduplicate hashes across pages before returning or processing the walk.

Also at `internal/watch/watch.go:194`.
</issue_to_address>

### Comment 5
<location path="internal/watch/watch.go" line_range="194" />
<code_context>
 func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
 	var res Result
-	items, err := c.UserItems(ctx, t.Hash)
+	items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")
 	if err != nil {
 		return Result{}, err
</code_context>
<issue_to_address>
**Previously seen listings reappear as new**

When an existing seller watch has had an out-of-page listing deleted from its stored `seen` rows by the old first-page-only behavior, and the watch is checked after upgrading, the full walk now returns page-two listings whose rows an earlier first-page-only check deleted from `seen`; `checkSeller` treats each missing hash as unknown and emits `seller.new_item`, so the first check after upgrading reports existing listings as new.

Account for pre-upgrade watches with already-deleted seen rows, for example by rebaselining affected seller watches or retaining enough state to distinguish recovered listings from genuinely new ones.
</issue_to_address>

### Comment 6
<location path="internal/watch/watch.go" line_range="214" />
<code_context>
+	// truncated it, hashes outside the fetched pages may just sit on a later
+	// page: reporting them gone would be a false alarm, so stay silent and
+	// wait for a walk that fits (the seller may list less) or the next check.
+	if truncated == "" {
+		for hash, prev := range seen {
+			if !current[hash] {
</code_context>
<issue_to_address>
**Truncated watches hide missed removals**

When a seller has more listings than the 50-page bound and the walk keeps truncating, `checkSeller` skips the removal sweep on a truncated walk without surfacing that the check was incomplete. For sellers whose listings remain beyond the 50-page limit, removals outside the fetched pages stay unreported and operators receive no indication that the watch cannot verify them.

Expose the incomplete-walk status to watch-check callers and report it to stderr or in the check result while continuing to suppress unverified removal events.
</issue_to_address>

### Comment 7
<location path="internal/cli/item.go" line_range="623" />
<code_context>
+			if err != nil {
+				return err
+			}
+			return a.Printer.Print(itemsView{Items: items, NextPage: cursor})
 		},
+	}
</code_context>
<issue_to_address>
**Pretty output hides the full cursor**

When pretty output displays a next-page token longer than 24 characters, `itemsView.Pretty` truncates the token, so users cannot pass the displayed value back to `--next` and must switch formats to resume.

Display the complete next-page token in pretty output.
</issue_to_address>

### Comment 8
<location path="internal/cli/cli_test.go" line_range="650" />
<code_context>
+	}
+	h.must("", "watch", "add", "seller", "other-seller-68037934", "--name", "fran")
+	r := h.must("", "watch", "check", "fran")
+	if strings.Contains(r.stdout, `"item.removed"`) {
+		t.Fatalf("truncated walk must not report removals:\n%s", r.stdout)
+	}
</code_context>
<issue_to_address>
**Truncated watch regression passes**

When the removal sweep is enabled and the first 50 items remain unchanged between the baseline and check, `TestSellerWatchDoesNotReportRemovedWhenWalkTruncates` passes with the removal sweep enabled: its add and check use the same first 50 items, so none of the hashes in `seen` are missing. The assertion never exercises a previously seen item beyond the fetched pages, allowing false-removal reports on truncated walks to return.

Arrange for a previously seen item to be absent from the fetched 50 pages during the check, then assert that no removal is emitted while the walk is truncated.
</issue_to_address>

### Comment 9
<location path="internal/cli/cli_test.go" line_range="630" />
<code_context>
+	// ghost-remove it, and the real removal is reported exactly once.
+	items[0].Removed = true
+	r := h.must("", "watch", "check", "fran", "--format", "jsonl")
+	if strings.Count(r.stdout, `"item.removed"`) != 1 || !strings.Contains(r.stdout, "hash00000000") {
+		t.Fatalf("events:\n%s", r.stdout)
+	}
</code_context>
<issue_to_address>
**Page-two watch regression passes**

When the watch implementation reads only page 1 and the first of the three fixture items is removed, `TestSellerWatchWalksAllPages` passes with a first-page-only watch: its baseline records only items 0 and 1; after item 0 is removed, items 1 and 2 both fit on page 1, so item 2 appears as a `seller.new_item` and the assertion at `internal/cli/cli_test.go:630` ignores it. The next check then reports item 2 removed, satisfying the second assertion too.

Keep enough items active after removing the first one that a page-one-only check still misses a previously seen item, and assert that no `seller.new_item` event is emitted for the page-two item.
</issue_to_address>

### Comment 10
<location path="internal/cli/item.go" line_range="590" />
<code_context>
+	var itemsNext string
+	var itemsAll bool
+	var itemsCmd = &cobra.Command{
+		Use: "items USER", Short: "Active listings", Args: cobra.ExactArgs(1),
+		Long: `List a seller's active listings. Wallapop pages this endpoint 40 items at a
+time: a plain call returns one page with its next_page cursor, --all walks
</code_context>
<issue_to_address>
**Help uses a prohibited term**

When the new help, reference text, and code comments describe Items as listings, the command help, reference text, and code comments call Items “listings,” so the new material uses terminology the repository glossary says to avoid.

Replace “listing(s)” with the glossary-approved term “Item(s)” in the changed text.

Also at `internal/cli/item.go:591`, `docs-site/content/docs/reference/user.mdx:16`, `docs-site/content/docs/reference/user.mdx:22`, `internal/wallapop/items.go:141-142`.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 9 findings to address first, and if the API repeats a pagination cursor, the walk treats that as complete even though later pages may be missing, so the seller watch can emit false removal events for items it did not fetch. The affected watch state is bounded, but reverting cannot retract an event already emitted.

Blocking findings: internal/wallapop/users.go:165, internal/watch/watch.go:194, internal/watch/watch.go:194, internal/wallapop/users.go:163, internal/watch/watch.go:194, and 4 more


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

Comment thread internal/wallapop/users.go Resolved
Comment thread internal/watch/watch.go
func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
var res Result
items, err := c.UserItems(ctx, t.Hash)
items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Existing Items reported as new

When a seller exceeds 50 pages and a previously unfetched Item later enters the fetched range, checkSeller emits new-item events from partial results and CommitCheck marks a truncated baseline complete, so the existing Item is absent from seen and appears new.

Keep truncated baselines incomplete and defer new-item events until a complete walk can establish the prior set.

Also at internal/watch/watch.go:214.

Prompt for AI agents
In `internal/watch/watch.go` at line 194:

**Existing Items reported as new**

When a seller exceeds 50 pages and a previously unfetched Item later enters the fetched range, `checkSeller` emits new-item events from partial results and `CommitCheck` marks a truncated baseline complete, so the existing Item is absent from `seen` and appears new.

Keep truncated baselines incomplete and defer new-item events until a complete walk can establish the prior set.

Also at `internal/watch/watch.go:214`.

Comment thread internal/watch/watch.go
func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
var res Result
items, err := c.UserItems(ctx, t.Hash)
items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Overlapping checks duplicate events

When a scheduled check overlaps a manual or second scheduled check for the same watch, two watch check runs can read the same prior seen state while this multi-page walk is in progress, independently produce the same events, deliver them, and commit them. SQLite’s single-writer setting serializes writes but not the fetch-and-diff interval, so users receive duplicate notifications; an older run can also commit stale state after a newer one.

Serialize checks per watch or use a version/lease mechanism that prevents stale checks from delivering and committing after a newer check.

Prompt for AI agents
In `internal/watch/watch.go` at line 194:

**Overlapping checks duplicate events**

When a scheduled check overlaps a manual or second scheduled check for the same watch, two `watch check` runs can read the same prior `seen` state while this multi-page walk is in progress, independently produce the same events, deliver them, and commit them. SQLite’s single-writer setting serializes writes but not the fetch-and-diff interval, so users receive duplicate notifications; an older run can also commit stale state after a newer one.

Serialize checks per watch or use a version/lease mechanism that prevents stale checks from delivering and committing after a newer check.

if err != nil {
return items, "", err
}
items = append(items, batch...)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Overlapping pages produce duplicates

When seller listings shift between page requests and an Item appears on multiple pages, UserItemsAll appends repeated hashes and checkSeller compares each copy against the unchanged prior seen map, so user items --all returns duplicate rows and a check emits duplicate events.

Deduplicate hashes across pages before returning or processing the walk.

Also at internal/watch/watch.go:194.

Prompt for AI agents
In `internal/wallapop/users.go` at line 163:

**Overlapping pages produce duplicates**

When seller listings shift between page requests and an Item appears on multiple pages, `UserItemsAll` appends repeated hashes and `checkSeller` compares each copy against the unchanged prior `seen` map, so `user items --all` returns duplicate rows and a check emits duplicate events.

Deduplicate hashes across pages before returning or processing the walk.

Also at `internal/watch/watch.go:194`.

Comment thread internal/watch/watch.go
func checkSeller(ctx context.Context, c *wallapop.Client, w store.Watch, t SellerTarget, seen map[string]store.Seen, baseline bool) (Result, error) {
var res Result
items, err := c.UserItems(ctx, t.Hash)
items, truncated, err := c.UserItemsAll(ctx, t.Hash, "")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Previously seen listings reappear as new

When an existing seller watch has had an out-of-page listing deleted from its stored seen rows by the old first-page-only behavior, and the watch is checked after upgrading, the full walk now returns page-two listings whose rows an earlier first-page-only check deleted from seen; checkSeller treats each missing hash as unknown and emits seller.new_item, so the first check after upgrading reports existing listings as new.

Account for pre-upgrade watches with already-deleted seen rows, for example by rebaselining affected seller watches or retaining enough state to distinguish recovered listings from genuinely new ones.

Prompt for AI agents
In `internal/watch/watch.go` at line 194:

**Previously seen listings reappear as new**

When an existing seller watch has had an out-of-page listing deleted from its stored `seen` rows by the old first-page-only behavior, and the watch is checked after upgrading, the full walk now returns page-two listings whose rows an earlier first-page-only check deleted from `seen`; `checkSeller` treats each missing hash as unknown and emits `seller.new_item`, so the first check after upgrading reports existing listings as new.

Account for pre-upgrade watches with already-deleted seen rows, for example by rebaselining affected seller watches or retaining enough state to distinguish recovered listings from genuinely new ones.

Comment thread internal/watch/watch.go
// truncated it, hashes outside the fetched pages may just sit on a later
// page: reporting them gone would be a false alarm, so stay silent and
// wait for a walk that fits (the seller may list less) or the next check.
if truncated == "" {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Truncated watches hide missed removals

When a seller has more listings than the 50-page bound and the walk keeps truncating, checkSeller skips the removal sweep on a truncated walk without surfacing that the check was incomplete. For sellers whose listings remain beyond the 50-page limit, removals outside the fetched pages stay unreported and operators receive no indication that the watch cannot verify them.

Expose the incomplete-walk status to watch-check callers and report it to stderr or in the check result while continuing to suppress unverified removal events.

Prompt for AI agents
In `internal/watch/watch.go` at line 214:

**Truncated watches hide missed removals**

When a seller has more listings than the 50-page bound and the walk keeps truncating, `checkSeller` skips the removal sweep on a truncated walk without surfacing that the check was incomplete. For sellers whose listings remain beyond the 50-page limit, removals outside the fetched pages stay unreported and operators receive no indication that the watch cannot verify them.

Expose the incomplete-walk status to watch-check callers and report it to stderr or in the check result while continuing to suppress unverified removal events.

Comment thread internal/cli/item.go Outdated
if err != nil {
return err
}
return a.Printer.Print(itemsView{Items: items, NextPage: cursor})

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Pretty output hides the full cursor

When pretty output displays a next-page token longer than 24 characters, itemsView.Pretty truncates the token, so users cannot pass the displayed value back to --next and must switch formats to resume.

Display the complete next-page token in pretty output.

Prompt for AI agents
In `internal/cli/item.go` at line 623:

**Pretty output hides the full cursor**

When pretty output displays a next-page token longer than 24 characters, `itemsView.Pretty` truncates the token, so users cannot pass the displayed value back to `--next` and must switch formats to resume.

Display the complete next-page token in pretty output.

Comment thread internal/cli/cli_test.go
}
h.must("", "watch", "add", "seller", "other-seller-68037934", "--name", "fran")
r := h.must("", "watch", "check", "fran")
if strings.Contains(r.stdout, `"item.removed"`) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Truncated watch regression passes

When the removal sweep is enabled and the first 50 items remain unchanged between the baseline and check, TestSellerWatchDoesNotReportRemovedWhenWalkTruncates passes with the removal sweep enabled: its add and check use the same first 50 items, so none of the hashes in seen are missing. The assertion never exercises a previously seen item beyond the fetched pages, allowing false-removal reports on truncated walks to return.

Arrange for a previously seen item to be absent from the fetched 50 pages during the check, then assert that no removal is emitted while the walk is truncated.

Prompt for AI agents
In `internal/cli/cli_test.go` at line 650:

**Truncated watch regression passes**

When the removal sweep is enabled and the first 50 items remain unchanged between the baseline and check, `TestSellerWatchDoesNotReportRemovedWhenWalkTruncates` passes with the removal sweep enabled: its add and check use the same first 50 items, so none of the hashes in `seen` are missing. The assertion never exercises a previously seen item beyond the fetched pages, allowing false-removal reports on truncated walks to return.

Arrange for a previously seen item to be absent from the fetched 50 pages during the check, then assert that no removal is emitted while the walk is truncated.

Comment thread internal/cli/cli_test.go
// ghost-remove it, and the real removal is reported exactly once.
items[0].Removed = true
r := h.must("", "watch", "check", "fran", "--format", "jsonl")
if strings.Count(r.stdout, `"item.removed"`) != 1 || !strings.Contains(r.stdout, "hash00000000") {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium · Page-two watch regression passes

When the watch implementation reads only page 1 and the first of the three fixture items is removed, TestSellerWatchWalksAllPages passes with a first-page-only watch: its baseline records only items 0 and 1; after item 0 is removed, items 1 and 2 both fit on page 1, so item 2 appears as a seller.new_item and the assertion at internal/cli/cli_test.go:630 ignores it. The next check then reports item 2 removed, satisfying the second assertion too.

Keep enough items active after removing the first one that a page-one-only check still misses a previously seen item, and assert that no seller.new_item event is emitted for the page-two item.

Prompt for AI agents
In `internal/cli/cli_test.go` at line 630:

**Page-two watch regression passes**

When the watch implementation reads only page 1 and the first of the three fixture items is removed, `TestSellerWatchWalksAllPages` passes with a first-page-only watch: its baseline records only items 0 and 1; after item 0 is removed, items 1 and 2 both fit on page 1, so item 2 appears as a `seller.new_item` and the assertion at `internal/cli/cli_test.go:630` ignores it. The next check then reports item 2 removed, satisfying the second assertion too.

Keep enough items active after removing the first one that a page-one-only check still misses a previously seen item, and assert that no `seller.new_item` event is emitted for the page-two item.

Comment thread internal/cli/item.go Outdated
var itemsNext string
var itemsAll bool
var itemsCmd = &cobra.Command{
Use: "items USER", Short: "Active listings", Args: cobra.ExactArgs(1),

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚪ Low · Help uses a prohibited term

When the new help, reference text, and code comments describe Items as listings, the command help, reference text, and code comments call Items “listings,” so the new material uses terminology the repository glossary says to avoid.

Replace “listing(s)” with the glossary-approved term “Item(s)” in the changed text.

Also at internal/cli/item.go:591, docs-site/content/docs/reference/user.mdx:16, docs-site/content/docs/reference/user.mdx:22, internal/wallapop/items.go:141-142.

Prompt for AI agents
In `internal/cli/item.go` at line 590:

**Help uses a prohibited term**

When the new help, reference text, and code comments describe Items as listings, the command help, reference text, and code comments call Items “listings,” so the new material uses terminology the repository glossary says to avoid.

Replace “listing(s)” with the glossary-approved term “Item(s)” in the changed text.

Also at `internal/cli/item.go:591`, `docs-site/content/docs/reference/user.mdx:16`, `docs-site/content/docs/reference/user.mdx:22`, `internal/wallapop/items.go:141-142`.

From AGENTS.md L9-11:

**Item**:
A single listing on Wallapop, identified by its 12-character hash. The numeric id in web URLs is an alias that resolves to the hash.
_Avoid_: Listing, product, ad, post

- Keep next_page present as an empty string on the final user-items page.
- Return a cursor-stalled error instead of reporting a repeated cursor as
  successful exhaustion.
- Preserve and print successful pages plus the last resume cursor when a
  later page request fails, while still returning the request error.
- Assert ordered hashes, the exact bound cursor and a successful resume.
- Use Item terminology in CLI help and generated docs.
checkSeller compared the seen hashes against only the first page of the
seller's items, so with more than 40 listings every check reported false
item.removed events for items that had merely scrolled to a later page
(and ghost recoveries when they scrolled back).

- Add Client.UserItemsAll: sequential bounded walk (MaxItemWalkPages,
  renamed from maxOwnItemPages and now shared with MyItem) returning the
  pending cursor when the bound truncates the list.
- checkSeller uses the walk and skips the removal sweep while the list is
  truncated: an absent hash may sit on an unfetched page, so staying
  silent beats a false alarm. `user items --all` reuses the same walk.
@JcMinarro
JcMinarro force-pushed the fix/watch-seller-pagination branch from 0bef250 to fa953bc Compare November 15, 2026 14:07
@JcMinarro

JcMinarro commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor Author

Addressed the review finding in commit fa953bc. UserItemsAll preserves successful Items and the cursor on a later-page failure, and treats a repeated cursor as an explicit incomplete-walk error. checkSeller aborts that check before the removal sweep on errors; it also skips the sweep when a bounded walk returns a pending cursor. Added a stalled-cursor seller-watch regression test. Verified with go test ./... -count=1 (242 tests) and go build ./....

@Microck
Microck merged commit a84a9e6 into Microck:main Nov 15, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants